package org.jeecg.modules.task;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.wdc.entity.CarDev;
import org.jeecg.modules.wdc.service.ICarDevService;
import org.jeecg.modules.wdc.service.ICarDrivingrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhengch
 * @date 2021年09月26日 5:22 下午
 */


@Component
public class DahuaDataUtil {

    @Autowired
    private ICarDrivingrecordService iCarDrivingrecordService;

    @Autowired
    private ICarDevService carDevService;

    @Resource(name = "asyncServiceExecutor")
    private ThreadPoolTaskExecutor execute;

    //是否自定义时间
    @Value("${dahuaCj.isCustomTime}")
    private  Boolean isCustomTime;
    //自定义时间
    @Value("${dahuaCj.customTime}")
    private  String customTime;


    public  void  getDahuaData(){
        QueryWrapper<CarDev> wrapper = new QueryWrapper<>();
        wrapper.lambda().like(CarDev::getDevchnid,"$");
        List<CarDev> list = carDevService.list(wrapper);
        for (CarDev carDev :list){
         execute.execute( new DahuaData(carDev.getDevchnid(),iCarDrivingrecordService,isCustomTime,customTime));
        }
    }
}
